//
// Created by yfux on 2022/4/18.
//

#ifndef ICANLIVE_JAVACALLHELPER_H
#define ICANLIVE_JAVACALLHELPER_H

#include <jni.h>

//线程标记
#define THREAD_MAIN 1
#define THREAD_CHILD 2

//错误代码宏
//打不开开视频
#define FFMPEG_CAN_NOT_OPEN_URL 1
//找不到流媒体
#define FFMPEG_CAN_NOT_FIND_STREAMS 2
//找不到解码器
#define FFMPEG_FIND_DECODER_FAIL 3
//无法根据解码器创建上下文
#define FFMPEG_ALLOC_CODEC_CONTEXT_FAIL 4
//无法根据信息流配置上下文参数
#define FFMPEG_CODEC_CONTEXT_PARAMETERS_FAIL 6
//打开解码器失败
#define FFMPEG_OPEN_DECODER_FAIL 7
//没有音视频
#define FFMPEG_NO_MEDIA 8

class JavaCallHelper {
public:
    void onError(int code, int thread = THREAD_MAIN);

    void onPrepare(int width, int height, int thread = THREAD_MAIN);

    void onProgress(int progress, int thread = THREAD_MAIN);

public:
    JavaCallHelper(JavaVM *pVm, JNIEnv *pEnv, jobject pJobject);

public:
    virtual ~JavaCallHelper();

private:
    jobject jobj;
    jmethodID jmid_error;
    jmethodID jmid_prepare;
    jmethodID jmid_progress;
    JavaVM *javaVm;
    JNIEnv *env;
};


#endif //ICANLIVE_JAVACALLHELPER_H
